﻿using WeDonekRpc.Helper;
using WeDonekRpc.Helper.Validate;

namespace Basic.FlowRemoteModel.EventTemplate.Model
{
    public class RpcParamConfig
    {
        /// <summary>
        /// 指令
        /// </summary>
        [NullValidate("flow.event.rpc.dictate.null")]
        public string SysDictate
        {
            get;
            set;
        }
        /// <summary>
        /// 服务器类型
        /// </summary>
        [EntrustValidate("_Check")]
        public string TypeVal
        {
            get;
            set;
        }
        /// <summary>
        /// 服务节点Id
        /// </summary>
        public long? ServerId
        {
            get;
            set;
        }

        /// <summary>
        /// 是否同步启动同步锁(解决客户端重复提交问题)
        /// </summary>
        public bool IsEnableLock { get; set; }


        /// <summary>
        /// 负载均衡方案
        /// </summary>
        public string Transmit { get; set; }

        public bool IsReply { get; set; } = false;

        private bool _Check ( RpcParamConfig config, out string error )
        {
            if ( config.ServerId.HasValue == false && config.TypeVal.IsNull() )
            {
                error = "flow.event.rpc.target.null";
                return false;
            }
            error = null;
            return true;
        }

    }
}
